package com.ysqcould.Community.service.impl;


import com.ysqcould.Community.domain.VolActivity;
import com.ysqcould.Community.mapper.VolActivityMapper;
import com.ysqcould.Community.service.IVolActivityService;
import com.ysqcould.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 义工活动信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-30
 */
@Service
public class VolActivityServiceImpl implements IVolActivityService
{
    @Autowired
    private VolActivityMapper volActivityMapper;

    /**
     * 查询义工活动信息
     * 
     * @param id 义工活动信息主键
     * @return 义工活动信息
     */
    @Override
    public VolActivity selectVolActivityById(Long id)
    {
        return volActivityMapper.selectVolActivityById(id);
    }

    /**
     * 查询义工活动信息列表
     * 
     * @param volActivity 义工活动信息
     * @return 义工活动信息
     */
    @Override
    public List<VolActivity> selectVolActivityList(VolActivity volActivity)
    {
        return volActivityMapper.selectVolActivityList(volActivity);
    }

    /**
     * 新增义工活动信息
     * 
     * @param volActivity 义工活动信息
     * @return 结果
     */
    @Override
    public int insertVolActivity(VolActivity volActivity)
    {
        volActivity.setCreateTime(DateUtils.getNowDate());
        return volActivityMapper.insertVolActivity(volActivity);
    }

    /**
     * 修改义工活动信息
     * 
     * @param volActivity 义工活动信息
     * @return 结果
     */
    @Override
    public int updateVolActivity(VolActivity volActivity)
    {
        volActivity.setUpdateTime(DateUtils.getNowDate());
        return volActivityMapper.updateVolActivity(volActivity);
    }

    /**
     * 批量删除义工活动信息
     * 
     * @param ids 需要删除的义工活动信息主键
     * @return 结果
     */
    @Override
    public int deleteVolActivityByIds(Long[] ids)
    {
        return volActivityMapper.deleteVolActivityByIds(ids);
    }

    /**
     * 删除义工活动信息信息
     * 
     * @param id 义工活动信息主键
     * @return 结果
     */
    @Override
    public int deleteVolActivityById(Long id)
    {
        return volActivityMapper.deleteVolActivityById(id);
    }

    @Override
    public int updateStatus(VolActivity activity) {
        VolActivity volActivity = volActivityMapper.selectVolActivityById(activity.getId());
        volActivity.setStatus(activity.getStatus());
        return volActivityMapper.updateVolActivity(volActivity);
    }
}
